package com.han.hotelplat.comm.utils;

import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import javax.servlet.http.HttpServletRequest;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class RequestParamUtils {
	public static String parseParamToJSON(HttpServletRequest req) {
		Map<String, String[]> reqparam = req.getParameterMap();
		System.out.println(JSON.toJSONString(req.getParameterMap()));
		Iterator<Entry<String, String[]>> its = reqparam.entrySet().iterator();
		Map<String, Object> param = new HashMap<>();
		while (its.hasNext()) {
			Entry<String, String[]> en = its.next();
			String key = en.getKey();
			String[] values = en.getValue();
			Object value = "";
			if (values != null && values.length > 1) {// 数组
				value = values;
			} else {
				value = values == null ? "" : values[0];
			}
			if(value instanceof Date){
				System.out.println(123);
			}
			param.put(key, value);
		}
		return JSONObject.toJSONString(param);
	}
}
